package com.cgs.mongo.extractor;

import com.cgs.mongo.exception.ExtractException;
import com.mongodb.client.MongoCursor;
import org.bson.BsonDocument;

/**
 * 迭代器中转化器
 *
 * @param <T>
 * @see AbstractCursorExtractor#forEach(MongoCursor, RowMapper)
 */
public interface RowMapper<T> {
    /**
     * 行转化
     *
     * @param bd     行数据
     * @param rowNum 行号
     * @return 转换后的对象
     * @throws ExtractException
     */
    T mapRow(BsonDocument bd, int rowNum) throws ExtractException;
}
